<template>
    <div class="header">
        <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect">
            <p class="logo">
                <router-link to="/index">
                <img src="../assets/logo.png" v-show="com_id==1">
                <img :src="logo" v-show="com_id!=1">
                </router-link>
            </p>
            <el-menu-item index="1">
                <router-link to="/index">首页</router-link>
            </el-menu-item>
            <el-menu-item index="2">
                <router-link to="/product" class="intro_pro">产品介绍</router-link>
            </el-menu-item>
            <el-menu-item index="3">
                <router-link to="/news" class="company_news">企业动态</router-link>
            </el-menu-item>
            <el-menu-item index="4">
                <router-link to="/video" class="company_video">视频</router-link>
            </el-menu-item>
            <el-menu-item index="5">
                <router-link to="/jobs">招贤纳士</router-link>
            </el-menu-item>
            <el-menu-item index="6">
                <router-link to="/about">关于我们</router-link>
            </el-menu-item>
            <!-- <el-menu-item index="6" class="login_backstage">
                <router-link to="/about">
                    <el-dropdown :hide-on-click="false">
                        <span class="el-dropdown-link">
                            我已登录    
                            <i class="el-icon-caret-bottom el-icon--right"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item>天化云化工</el-dropdown-item>
                            <el-dropdown-item>修改</el-dropdown-item>
                            <el-dropdown-item>退出登录</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </router-link>
            </el-menu-item> -->
        </el-menu>
    </div>
</template>

<script>
export default {
    data() {
        return {
            activeIndex: '1',
            activeIndex2: '1',
            logo:[],
            com_id:localStorage.getItem("companyid"),
        };
    },
    created:function(){
        var domain=window.location.href;
        var sec=domain.split(".")[0];
        var secs=sec.replace(/\//g, "");
        var api=secs.replace(/http:/, "");
        this.api=api;
        
    },
     mounted(){
        // alert('header-api-mounted')      
        this.loadApi();
    },
    methods: {
        loadApi(){
            this.$http.post('http://thy.588net.com/index.php/api/domain/get_domain',{pr:this.api},{emulateJSON: true}).then(function(res){
               
                 var com_ids=res.body.data.company_id;
                 this.com=com_ids; 
               
                //alert('api-contebnt')
                if(res.body.data.company_id || res.body.code==200){                                      
                    var com_id=localStorage.setItem('companyid',com_ids);
                    var scopeds=localStorage.getItem("companyid");
                    // alert('com_id'+scopeds)
                     this.loadLogo();                    
                }

                if(res.body.code==1002 || res.body.data==''){
                    var com_id=localStorage.setItem('companyid',1); 
                   this.loadLogo();               
                }  
              
            })
        },
        handleSelect(key, keyPath) {
            //console.log(key, keyPath);
        },
        loadLogo() {    
            var com_id=localStorage.getItem("companyid");       
            this.$http.get('http://thy.588net.com/index.php/api/Company/get_company_index?' + '&company_id=' + com_id+'&header='+1).then(function(res) {
                this.logo = res.body.data.company.pc_logo;
            })
        },
    }
    
}
</script>

<style scoped>
.header {
    background-color: #fff;
}


.header ul {
    max-width: 1200px;
    margin: 0 auto;
background: #fff;
    overflow: hidden;
}
.header ul li{
    overflow: hidden;
}


.header ul li a{
    padding: 0 20px;
}


.el-menu-item,
.el-submenu__title {
    margin: 0 20px!important;
}

.logo {
    float: left;
    margin-right: 40px;
    height: 60px;
}

.logo img {
    width: 170px;
    height: 50px;
    margin-top: 5px;
    vertical-align: bottom;
}

a {
    text-decoration: none;
    display: block;
    width: 100%;
    font-size: 16px
}
.el-menu-item, .el-submenu__title{
    padding: 0
}
.login_backstage {
    border-bottom: 0 solid #20a0ff!important;
}

.el-menu--horizontal>.el-menu-item:hover, .el-menu--horizontal>.el-submenu.is-active .el-submenu__title, .el-menu--horizontal>.el-submenu:hover .el-submenu__title {
    border-bottom: 5px solid #2277ff;
}
.header .is-active a{
color: #2277ff;
}

.is-active{
    color: #2277ff!important;
}

.active{
    color: #2277ff!important;
}
</style>
